package com.ceba.test.base.dbdata.modules;
import com.ceba.base.dbdata.DataTableObject;
import com.ceba.base.dbdata.MysqlUtils;
public class InterfaceDb {

	public static void init() throws Exception{
		//10-start
		DataTableObject dirmanagers=new DataTableObject("dirmanagers");
		dirmanagers.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		dirmanagers.addField("DIR_PATH", "varchar(255)", "DEFAULT NULL", "", "false");
		dirmanagers.addField("TEMP_DIR_PATH", "varchar(255)", "DEFAULT NULL", "", "false");
		dirmanagers.addField("SAVE_DIR_PATH", "varchar(255)", "DEFAULT NULL", "", "false");
		dirmanagers.addField("FAIL_DIR_PATH", "varchar(255)", "DEFAULT NULL", "", "false");
		dirmanagers.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		dirmanagers.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		dirmanagers.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		dirmanagers.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(dirmanagers);
		//end
		
		//26-start
		DataTableObject templates_word=new DataTableObject("templates_word");
		templates_word.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		templates_word.addField("WORD_GENERATE_NAME", "varchar(255)", "DEFAULT NULL", "", "false");
		templates_word.addField("WORD_NAME", "varchar(255)", "DEFAULT NULL", "", "false");
		templates_word.addField("WORD_PATH", "varchar(255)", "DEFAULT NULL", "", "false");
		templates_word.addField("WORD_VIRTUAL_PATH", "varchar(255)", "DEFAULT NULL", "", "false");
		templates_word.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		templates_word.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		templates_word.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		templates_word.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		templates_word.addField("STORAGE_ADDRESS_ID", "varchar(32)", "DEFAULT '55555555555555555555555555555555'", "", "false");
		MysqlUtils.syncTableStructure(templates_word);
		//end
		
	
		//20-start
		DataTableObject g_stamp=new DataTableObject("g_stamp");
		g_stamp.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_stamp.addField("USER_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_stamp.addField("RELACTION_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_stamp.addField("FILE_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_stamp.addField("MATCH_NAME", "varchar(500)", "DEFAULT NULL", "印章匹配", "false");
		g_stamp.addField("IMG_WIDTH", "float", "DEFAULT NULL", "", "false");
		g_stamp.addField("IMG_HEIGHT", "float", "DEFAULT NULL", "", "false");
		g_stamp.addField("FILE_PATH", "varchar(1000)", "DEFAULT NULL", "", "false");
		g_stamp.addField("KEY_NAME", "varchar(500)", "DEFAULT NULL", "", "false");
		g_stamp.addField("CLASS", "varchar(200)", "DEFAULT NULL", "", "false");
		g_stamp.addField("POSITION", "varchar(200)", "DEFAULT NULL", "", "false");
		g_stamp.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_stamp.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_stamp.addField("COR_FLAG", "varchar(512)", "DEFAULT '0'", "", "false");
		g_stamp.addField("COR_STAMP_NAME", "varchar(512)", "DEFAULT ''", "", "false");
		g_stamp.addField("STAMP_X", "varchar(512)", "DEFAULT '0'", "", "false");
		g_stamp.addField("STAMP_Y", "varchar(512)", "DEFAULT '0'", "", "false");
		g_stamp.addField("STAMP_PAGE", "varchar(512)", "DEFAULT '1'", "", "false");
		g_stamp.addField("CER_NO", "varchar(125)", "DEFAULT NULL", "证书号", "false");
		g_stamp.addField("ENCODE_SIGNTYPE", "int", "", "加密方式", "false");
		g_stamp.addField("STORAGE_ADDRESS_ID", "varchar(32)", "DEFAULT '55555555555555555555555555555555'", "", "false");
		
		MysqlUtils.syncTableStructure(g_stamp);


		//22
		DataTableObject g_signature_memory=new DataTableObject("g_signature_memory");
		g_signature_memory.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_signature_memory.addField("DIGITAL_SIGNATURE_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_signature_memory.addField("QIFENG_SIGNATURE_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_signature_memory.addField("REPORT_MERGE_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_signature_memory.addField("ORIGINAL_DOCUMENT", "varchar(32)", "DEFAULT NULL", "印章匹配", "false");
		g_signature_memory.addField("USER_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_signature_memory.addField("CORFLAG", "varchar(32)", "DEFAULT NULL", "", "false");
		g_signature_memory.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(g_signature_memory);

		//20-start
		DataTableObject g_water_page_number=new DataTableObject("g_water_page_number");
		g_water_page_number.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_water_page_number.addField("G_STAMP_ID", "varchar(32)", "NOT NULL", "", "false");
		g_water_page_number.addField("SELECT_FLAG", "varchar(10)", "NOT NULL", "", "false");
		g_water_page_number.addField("RADIO_FLAG", "varchar(10)", "DEFAULT NULL", "", "false");
		g_water_page_number.addField("SELECT_PAGE_NUMBER", "varchar(100)", "DEFAULT NULL", "", "false");
		g_water_page_number.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_water_page_number.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_water_page_number.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_water_page_number.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(g_water_page_number);



		
		//36-start
		DataTableObject g_user_cor_stamp=new DataTableObject("g_user_cor_stamp");
		g_user_cor_stamp.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_user_cor_stamp.addField("G_STAMP_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_user_cor_stamp.addField("AUTHORIZATION_TYPE", "int", "", "", "false");
		g_user_cor_stamp.addField("USER_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_user_cor_stamp.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_user_cor_stamp.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(g_user_cor_stamp);
		//end
		
		//38-start
		DataTableObject i_sign_rule=new DataTableObject("i_sign_rule");
		i_sign_rule.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		i_sign_rule.addField("SERVER_IP", "varchar(20)", "DEFAULT NULL", "", "false");
		i_sign_rule.addField("SERVER_PORT", "int", "DEFAULT 0", "", "false");
		i_sign_rule.addField("MULTI_SERVER", "varchar(20)", "DEFAULT NULL", "", "false");
		i_sign_rule.addField("KEY_TYPE", "int", "DEFAULT 0", "", "false");
		i_sign_rule.addField("ENCODE_SIGNTYPE", "int", "DEFAULT 0", "", "false");
		i_sign_rule.addField("CER_NO", "varchar(32)", "DEFAULT NULL", "", "false");
		i_sign_rule.addField("CERTIFICATION_LEVEL", "int", "DEFAULT 0", "0--修订 1-验证", "false");
		i_sign_rule.addField("SERVERURL_SUFFIX", "varchar(125)", "DEFAULT NULL", "服务器地址后缀", "false");
		i_sign_rule.addField("QF_RULE_ID", "varchar(32)", "DEFAULT NULL", "骑缝章规则id", "false");
		i_sign_rule.addField("OTHER_STAMP_ID", "varchar(32)", "DEFAULT NULL", "其他印章Id", "false");
		i_sign_rule.addField("SIGN_STAMP_ID", "varchar(32)", "DEFAULT NULL", "签名印章Id", "false");
		i_sign_rule.addField("WATER_STAMP_ID", "varchar(500)", "DEFAULT NULL", "水印Id", "false");
		i_sign_rule.addField("KEY_NAME", "varchar(500)", "DEFAULT NULL", "秘钥名称", "false");
		i_sign_rule.addField("MERGE_ID", "varchar(32)", "DEFAULT NULL", "首尾页Id", "false");
		i_sign_rule.addField("ALLOW_PDF_CONTENT_COPY", "int", "", "", "false");
		i_sign_rule.addField("ALLOW_PDF_PRINT", "int", "", "", "false");
		i_sign_rule.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		i_sign_rule.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(i_sign_rule);
		//end
		
		//39-start
		DataTableObject g_report_merge=new DataTableObject("g_report_merge");
		g_report_merge.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_report_merge.addField("NAME", "varchar(255)", "DEFAULT NULL", "", "false");
		g_report_merge.addField("COVER_FILE_PATH", "varchar(255)", "DEFAULT NULL", "", "false");
		g_report_merge.addField("COVER_FILE_URL", "varchar(255)", "DEFAULT NULL", "", "false");
		g_report_merge.addField("COVER_FILE_NAME", "varchar(255)", "DEFAULT NULL", "", "false");
		g_report_merge.addField("FOOTER_FILE_NAME", "varchar(255)", "DEFAULT '0'", "", "false");
		g_report_merge.addField("FOOTER_FILE_URL", "varchar(255)", "DEFAULT NULL", "", "false");
		g_report_merge.addField("FOOTER_FILE_PATH", "varchar(255)", "DEFAULT NULL", "", "false");
		g_report_merge.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_report_merge.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_report_merge.addField("STORAGE_ADDRESS_ID", "varchar(32)", "DEFAULT '55555555555555555555555555555555'", "", "false");
		MysqlUtils.syncTableStructure(g_report_merge);
		//end
		
		
		//41-start
		DataTableObject i_ftp_rule=new DataTableObject("i_ftp_rule");
		i_ftp_rule.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		i_ftp_rule.addField("FTP_FILE_NAME", "varchar(64)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_READ_USER", "varchar(64)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_READ_PWD", "varchar(64)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_READ_DIR", "varchar(64)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_WRITE_USER", "varchar(64)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_WRITE_PWD", "varchar(64)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_WRITE_DIR", "varchar(64)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_URL", "varchar(500)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_PORT", "varchar(64)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("FTP_FLAG", "varchar(32)", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		i_ftp_rule.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(i_ftp_rule);
		//end
		
		//43-start
		DataTableObject i_cus_rule=new DataTableObject("i_cus_rule");
		i_cus_rule.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		i_cus_rule.addField("RULE_NAME", "varchar(32)", "DEFAULT NULL", "自定义规则名称", "false");
		i_cus_rule.addField("RULE_PATH", "varchar(500)", "DEFAULT NULL", "自定义规则文件路径", "false");
		i_cus_rule.addField("POSITION", "int", "DEFAULT 1", "加盖骑缝章的位置 0-上边缘  1-左边缘  2-下边缘 3-右边缘", "false");
		i_cus_rule.addField("VERTICALAPEAK", "int", "DEFAULT 5", "边缘垂直占比  1-9 分别表示10%-90%", "false");
		i_cus_rule.addField("ODEVITY", "int", "DEFAULT 2", "骑缝章加盖的奇偶数  0-偶数 1-奇数 2-全部", "false");
		i_cus_rule.addField("SYNCOPATE", "int", "DEFAULT 0", "骑缝章的切割方式  0-均分  1-特殊情况", "false");
		i_cus_rule.addField("FRIST_APEAK", "int", "DEFAULT 5", "切割方式方式特殊情况下 首页占比 1-9 分别表示10%-90%", "false");
		i_cus_rule.addField("OUTHER_APEAK", "int", "DEFAULT 0", "切割方式方式特殊情况下 其他页0-均分 1-随机", "false");
		i_cus_rule.addField("RULE_TYPE", "int", "DEFAULT 0", "0-表示上传配置问件配置规则（比如佛山计量） 1-表示骑缝章规则配置   默认为0", "false");
		i_cus_rule.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		i_cus_rule.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(i_cus_rule);
		//end
		
		DataTableObject i_qifeng_rule=new DataTableObject("i_qifeng_rule");
		i_qifeng_rule.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		i_qifeng_rule.addField("RULE_NAME", "varchar(32)", "DEFAULT NULL", "自定义规则名称", "false");
		i_qifeng_rule.addField("FILE_PATH", "varchar(500)", "DEFAULT NULL", "自定义规则文件路径", "false");
		i_qifeng_rule.addField("IMG_WIDTH", "float", "DEFAULT 70", "", "false");
		i_qifeng_rule.addField("IMG_HEIGHT", "float", "DEFAULT 70", "", "false");
		i_qifeng_rule.addField("POSITION", "int", "DEFAULT 1", "加盖骑缝章的位置 0-上边缘  1-左边缘  2-下边缘 3-右边缘", "false");
		i_qifeng_rule.addField("VERTICALAPEAK", "int", "DEFAULT 5", "边缘垂直占比  1-9 分别表示10%-90%", "false");
		i_qifeng_rule.addField("ODEVITY", "int", "DEFAULT 2", "骑缝章加盖的奇偶数  0-偶数 1-奇数 2-全部", "false");
		i_qifeng_rule.addField("SYNCOPATE", "int", "DEFAULT 0", "骑缝章的切割方式  0-均分  1-特殊情况", "false");
		i_qifeng_rule.addField("FRIST_APEAK", "int", "DEFAULT 5", "切割方式方式特殊情况下 首页占比 1-9 分别表示10%-90%", "false");
		i_qifeng_rule.addField("OUTHER_APEAK", "int", "DEFAULT 0", "切割方式方式特殊情况下 其他页0-均分 1-随机", "false");
		i_qifeng_rule.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		i_qifeng_rule.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		i_qifeng_rule.addField("STORAGE_ADDRESS_ID", "varchar(32)", "DEFAULT '55555555555555555555555555555555'", "", "false");
		MysqlUtils.syncTableStructure(i_qifeng_rule);
	}

	public static void insertDefaultData() throws Exception {
		//更新默认
		MysqlUtils.updateField("COR_STAMP_NAME", "ceba审核章", "ID='66280ff6a6084825bace34015a9ecebf'", "g_stamp");
		MysqlUtils.updateField("COR_STAMP_NAME", "ceba编制章", "ID='ae8f3402a89a4cea819071204434a408'", "g_stamp");
		MysqlUtils.updateField("COR_STAMP_NAME", "ceba签发章", "ID='e11b58c1694d41c68b823bdf980a18fa'", "g_stamp");
		/*添加上传模板*/
		MysqlUtils.insertDataIntoTable("templates_word","(ID,WORD_GENERATE_NAME,WORD_NAME,WORD_VIRTUAL_PATH,STORAGE_ADDRESS_ID)","ID","1","'1', 'testTemplate.doc', 'testTemplate.doc', 'upfile/template/testTemplate.doc','55555555555555555555555555555555'");
		/**测试印章**/
		MysqlUtils.insertDataIntoTable("g_stamp","(ID,USER_ID,RELACTION_ID,FILE_ID,MATCH_NAME,IMG_WIDTH,IMG_HEIGHT,FILE_PATH,COR_FLAG,COR_STAMP_NAME,STAMP_X,STAMP_Y,STAMP_PAGE,STORAGE_ADDRESS_ID)","ID","1","'1', null, null, null, '$印章$', '75', '75', 'upfile/images/sign.png', '1', '测吧印章', '0', '0','1','55555555555555555555555555555555'");



		//管理员
		MysqlUtils.insertDataIntoTable("u_user","(ID,NAME,Password,Login_ID,IS_LOCKED)","ID","999999999999999999999999999999","'999999999999999999999999999999',  '系统管理员', 'H2NoRlsDs5sMhBLHxMarvQ==', 'admin', '0'");
		//加密员
		MysqlUtils.insertDataIntoTable("u_user","(ID,NAME,Password,Login_ID,IS_LOCKED)","ID","8c1ec0311e4c4881b49190ff84460c16","'8c1ec0311e4c4881b49190ff84460c16', '王乐', '4HxTGNNQUdzLUhB6cKo1qg==', 'wangle', '0'");
		//作废人
		MysqlUtils.insertDataIntoTable("u_user","(ID,NAME,Password,Login_ID,IS_LOCKED)","ID","verAdmin","'verAdmin', '验证平台管理员', '4HxTGNNQUdzLUhB6cKo1qg==', 'verAdmin', '0'");
		
		//加密员角色
		MysqlUtils.insertDataIntoTable("u_role","(ID,PID,Name,LOGIN_INDEX,Row_State,LOGIN_INDEX_SIGNVER,LOGIN_INDEX_SIGNONLY)","ID","109","'109', '0', '数字加密员', 'rms/modules/report/digitSignList.jsp', '1', 'rms/modules/signver/digitSignList.jsp', 'rms/modules/signonly/signManage.jsp'");
		//作废角色
		MysqlUtils.insertDataIntoTable("u_role","(ID,PID,Name,LOGIN_INDEX,Row_State,LOGIN_INDEX_SIGNVER,LOGIN_INDEX_SIGNONLY)","ID","200","'200', '0', '验证平台管理员', 'rms/modules/cnca/upInvalidReportCNCAList-FES.jsp', '1', NULL,'rms/modules/cnca/cncaReportList.jsp'");
		
		/**添加角色和人员之间关系***/
		MysqlUtils.insertDataIntoTable("u_privilege"," (ID,User_ID,Flag,Object_Id,Action_Indexs,MAction_Indexs,TAction_Indexs)","ID","f84eb62ef18d4b4d94dc862463276ddd","'f84eb62ef18d4b4d94dc862463276ddd', '8c1ec0311e4c4881b49190ff84460c16', '1', '109', '255', '255', '255'");
		MysqlUtils.insertDataIntoTable("u_privilege"," (ID,User_ID,Flag,Object_Id,Action_Indexs,MAction_Indexs,TAction_Indexs)","ID","verAdmin","'verAdmin', 'verAdmin', '1', '200', '255', '255', '255'");
        MysqlUtils.updateColumnName("g_user_cor_stamp","g_stamp_id","USER_AUTHORIZATION_ID");

        //修改lic日志字段
		MysqlUtils.updateColumnName("g_lic_log","ENTERPRISE_NAME","enterpriseId");

	}

	//添加索引
	public static void addIndex() throws Exception {
	}
}
